Fix jpg_quality/jpeg_quality field mismatch with OCRmyPDF >=17.10 - #63
Fix jpg_quality/jpeg_quality field mismatch with OCRmyPDF >=17.10#63tah0 wants to merge 1 commit into
Conversation
…tect which name is used to work with old and new versions of OCRmyPDF. OcrOptions field rename in 17.10 causes dpsprep to crash with a pydantic ValidationError when calling OCRmyPDF optimization (-O<n> flag).
|
Hello. Thank you for the fix. I'm afraid OCRmyPDF have entered their automated "move fast and break things" phase, so other things may break soon. Using the private Anyhow, one of the positive changes from them was to introduce type hints. I we un-ignore One way around this is to use the backwards-compatible setter, i.e. to construct If you do this fix, you can also commit the change in Now, regarding your comment
I believe I found the issue independently and will now do a fix. We create this temporary directory so that it can be reused it in case of an error, so deleting it automatically defeats its purpose. There is a setting, |
Any optimize level (
-O<n>) crashes on OCRmyPDF >=17.10.0 with:Reproduction
Any djvu file will do, e.g.:
wget -q -O sample.djvu "https://upload.wikimedia.org/wikipedia/commons/8/8d/Example_for_DjVu_manual_cz-book_color.djvu"The following crashes with the error above
uv run --with dpsprep --with 'ocrmypdf>=17.10' dpsprep -O1 sample.djvu sample.pdfCause
src/dpsprep/ocrmypdf_adapter.pyexpects the_options.OcrOptionsfieldjpg_quality, which was renamed tojpeg_qualityin OCRmyPDF 17.10.0 (6f4744dd). dpsprep constructsOcrOptionsdirectly instead of going throughocrmypdf.ocr(), which callscreate_options()to remap deprecated parameter names. So it isn't caught here.Fix
In
ocrmypdf_adapter.py, detect which field name the installed OCRmyPDF'sOcrOptionshas and use that:Works across both old 17.8.1 (pre-rename) and new >=17.10 (post-rename) OCRmyPDF versions.
Notes
/var/tmp/dpsprep/working dir and hangs. But to rerun dpsprep on the same input after a failure (like when testing for this error) you need to delete the old working dir first.